/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package ar.edu.utn.frsf.cidisi.upcolbpip.b2bcollaborations.impl;

import ar.edu.utn.frsf.cidisi.upcolbpip.b2bcollaborations.B2bcollaborationsPackage;
import ar.edu.utn.frsf.cidisi.upcolbpip.b2bcollaborations.PartnerRole;
import ar.edu.utn.frsf.cidisi.upcolbpip.b2bcollaborations.PublicBusinessInterface;

import ar.edu.utn.frsf.cidisi.upcolbpip.collaborativebusinessprocesses.CollaborativeBusinessProcess;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Partner Role</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link ar.edu.utn.frsf.cidisi.upcolbpip.b2bcollaborations.impl.PartnerRoleImpl#getName <em>Name</em>}</li>
 *   <li>{@link ar.edu.utn.frsf.cidisi.upcolbpip.b2bcollaborations.impl.PartnerRoleImpl#getPublicInterfaces <em>Public Interfaces</em>}</li>
 *   <li>{@link ar.edu.utn.frsf.cidisi.upcolbpip.b2bcollaborations.impl.PartnerRoleImpl#getParticipates <em>Participates</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class PartnerRoleImpl extends EObjectImpl implements PartnerRole {
	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The cached value of the '{@link #getPublicInterfaces() <em>Public Interfaces</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPublicInterfaces()
	 * @generated
	 * @ordered
	 */
	protected EList<PublicBusinessInterface> publicInterfaces;

	/**
	 * The cached value of the '{@link #getParticipates() <em>Participates</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getParticipates()
	 * @generated
	 * @ordered
	 */
	protected EList<CollaborativeBusinessProcess> participates;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PartnerRoleImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return B2bcollaborationsPackage.Literals.PARTNER_ROLE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, B2bcollaborationsPackage.PARTNER_ROLE__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<PublicBusinessInterface> getPublicInterfaces() {
		if (publicInterfaces == null) {
			publicInterfaces = new EObjectContainmentEList<PublicBusinessInterface>(PublicBusinessInterface.class, this, B2bcollaborationsPackage.PARTNER_ROLE__PUBLIC_INTERFACES);
		}
		return publicInterfaces;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<CollaborativeBusinessProcess> getParticipates() {
		if (participates == null) {
			participates = new EObjectResolvingEList<CollaborativeBusinessProcess>(CollaborativeBusinessProcess.class, this, B2bcollaborationsPackage.PARTNER_ROLE__PARTICIPATES);
		}
		return participates;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case B2bcollaborationsPackage.PARTNER_ROLE__PUBLIC_INTERFACES:
				return ((InternalEList<?>)getPublicInterfaces()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case B2bcollaborationsPackage.PARTNER_ROLE__NAME:
				return getName();
			case B2bcollaborationsPackage.PARTNER_ROLE__PUBLIC_INTERFACES:
				return getPublicInterfaces();
			case B2bcollaborationsPackage.PARTNER_ROLE__PARTICIPATES:
				return getParticipates();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case B2bcollaborationsPackage.PARTNER_ROLE__NAME:
				setName((String)newValue);
				return;
			case B2bcollaborationsPackage.PARTNER_ROLE__PUBLIC_INTERFACES:
				getPublicInterfaces().clear();
				getPublicInterfaces().addAll((Collection<? extends PublicBusinessInterface>)newValue);
				return;
			case B2bcollaborationsPackage.PARTNER_ROLE__PARTICIPATES:
				getParticipates().clear();
				getParticipates().addAll((Collection<? extends CollaborativeBusinessProcess>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case B2bcollaborationsPackage.PARTNER_ROLE__NAME:
				setName(NAME_EDEFAULT);
				return;
			case B2bcollaborationsPackage.PARTNER_ROLE__PUBLIC_INTERFACES:
				getPublicInterfaces().clear();
				return;
			case B2bcollaborationsPackage.PARTNER_ROLE__PARTICIPATES:
				getParticipates().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case B2bcollaborationsPackage.PARTNER_ROLE__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case B2bcollaborationsPackage.PARTNER_ROLE__PUBLIC_INTERFACES:
				return publicInterfaces != null && !publicInterfaces.isEmpty();
			case B2bcollaborationsPackage.PARTNER_ROLE__PARTICIPATES:
				return participates != null && !participates.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(')');
		return result.toString();
	}

} //PartnerRoleImpl
